package com.only4play.productcenter.infrastructure.convert;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-02-28
 */

import com.only4play.productcenter.api.constants.TemplateType;

import javax.persistence.AttributeConverter;

public class TemplateTypeConverter implements AttributeConverter<TemplateType, Integer> {

    @Override
    public Integer convertToDatabaseColumn(TemplateType templateType) {
        return templateType.getCode();
    }

    @Override
    public TemplateType convertToEntityAttribute(Integer code) {
        return TemplateType.of(code).orElse(null);
    }
}
